package flc.ast;

import android.graphics.Color;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.huawei.hms.videoeditor.HmsVeModule;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.ConversionFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.PlayFragment;
import flc.ast.fragment.VideoFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

//    @Override
//    protected void onHandleStatusBar() {
//        super.onHandleStatusBar();
////        StatusBarUtils.setStatusTransparent(this);
//        //设置状态栏字体颜色
//        StatusBarUtils.setSystemStatusTextColor(true, this);
//    }


    @Override
    protected void onHandleStatusBar() {
        StatusBarUtils.with(this).init();
        StatusBarUtils.setStatusBarTranslate(this, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }

    @Override
    protected void initData() {
        HmsVeModule.init(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(PlayFragment.class, R.id.llPlay));
        listFragment.add(new FragmentViewBinder(ConversionFragment.class, R.id.llConversion));
        listFragment.add(new FragmentViewBinder(VideoFragment.class, R.id.llVideo));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.tab_1a);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#FF5034"));
                break;
            case R.id.llPlay:
                mDataBinding.ivPlay.setImageResource(R.drawable.tab_2a);
                mDataBinding.tvPlay.setTextColor(Color.parseColor("#FF5034"));
                break;
            case R.id.llConversion:
                mDataBinding.ivConversion.setImageResource(R.drawable.tab_3a);
                mDataBinding.tvConversion.setTextColor(Color.parseColor("#FF5034"));
                break;
            case R.id.llVideo:
                mDataBinding.ivVideo.setImageResource(R.drawable.tab_4a);
                mDataBinding.tvVideo.setTextColor(Color.parseColor("#FF5034"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.tab_5a);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#FF5034"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.tab_1);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#907F8A"));
        mDataBinding.ivPlay.setImageResource(R.drawable.tab_2);
        mDataBinding.tvPlay.setTextColor(Color.parseColor("#907F8A"));
        mDataBinding.ivConversion.setImageResource(R.drawable.tab_3);
        mDataBinding.tvConversion.setTextColor(Color.parseColor("#907F8A"));
        mDataBinding.ivVideo.setImageResource(R.drawable.tab_4);
        mDataBinding.tvVideo.setTextColor(Color.parseColor("#907F8A"));
        mDataBinding.ivMy.setImageResource(R.drawable.tab_5);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#907F8A"));
    }

}